import os


path1 = "D:\work\\advi\\app\data\ply\\"
# print(os.path.basename(path1))
#
#
# dirs = os.listdir(path1)
# for i in range(len(dirs)):
#     if 0<= i < 10:
#         dir = "pt00" + str(i) + "-label"
#     elif 10 <= i < 100:
#         dir = "pt0" + str(i) + "-label"
#     else:
#         dir = "pt" + str(i) + "-label"
#     print(dir)
#     old_path = os.path.join(path1, dirs[i])
#
#     new_path = path1 + dir
#     print(old_path, new_path)
#     os.rename(old_path, new_path)

listDir = os.listdir(path1)
for i in listDir:
    dir = path1 + i
    print(dir)
    listfile = os.listdir(dir)
    for file in listfile:
        filename = file[:-3]
        tip = file[-3:]
        print(file, filename, tip)
        print( dir+"/"+i+"."+tip)
        # if filename != i:
        os.rename(os.path.join(dir, file), dir+"/"+i+"."+tip)







